package controller;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JPanel;

import model.Model;

import view.View;
import view.ViewAbstract;
import view.items.PanelAbstract;
import view.items.PanelCallRequest;
public class ControllerLighter implements MouseListener {
	
	private PanelAbstract panelAbstract;
	private Model model;
	private View view;
	
	public ControllerLighter(Model model) {
		this.model=model;
	}

	public PanelAbstract getPanelAbstract() {
		return panelAbstract;
	}

	public void setPanelAbstract(PanelAbstract panelAbstract) {
		this.panelAbstract = panelAbstract;
	}

	public View getView() {
		return view;
	}

	public void setView(View view) {
		this.view = view;
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		//System.out.println("mouseclicked");
		this.panelAbstract=(PanelAbstract) arg0.getComponent();
		this.model.resetClicked();

		this.panelAbstract.getCall().setClickedOnGui(true);
		this.model.setCallSelected(this.panelAbstract.getCall());
		this.view.refreshAll();
		
	}


	@Override
	public void mouseEntered(MouseEvent arg0) {
		//System.out.println("mouse enter");
		this.panelAbstract=(PanelAbstract) arg0.getComponent();
		if(!this.panelAbstract.getCall().isClickedOnGui()){
		this.panelAbstract.setBackground(new Color((int) 0x388df9));
		this.panelAbstract.getComponent(0).setForeground(Color.white);
		this.panelAbstract.getComponent(1).setForeground(Color.white);
		this.panelAbstract.getComponent(2).setForeground(Color.white);
		}
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		//System.out.println("mouseexit");
		this.panelAbstract=(PanelAbstract) arg0.getComponent();
		if(!this.panelAbstract.getCall().isClickedOnGui()){
		this.panelAbstract.setBackground(Color.LIGHT_GRAY);
		this.panelAbstract.getComponent(0).setForeground(Color.darkGray);
		this.panelAbstract.getComponent(1).setForeground(Color.darkGray);
		this.panelAbstract.getComponent(2).setForeground(Color.darkGray);
		}
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

}
